﻿@model IEnumerable<CodeCamp.Models.Email.EmailItemListItem>

<table>
    <tr>
        <th>Actions</th>
        <th>id</th>
        <th>Send Status</th>
        <th>Sent (UTC)</th>
        <th>Email To</th>
        <th>First Name</th>
        <th>Last Name</th>
        <th>Subject</th>
        <th>Sent By</th>
    </tr>
@foreach (var item in Model) {
    <tr>
        <td>
            @{
                bool prevLink = false;
                if ((item.SendStatus != CodeCamp.Model.EmailItem.EmailSendStatus.Sent) && (item.SendStatus != CodeCamp.Model.EmailItem.EmailSendStatus.Cancelled))
                {
                    prevLink = true;
                @Html.ActionLink("Edit", "EmailItemEdit", "Email", new { eventName=item.EventShortName, id=item.EmailItemId }, null)
                }
                if (prevLink)
                {
                    <text> | </text>
                }
                @Html.ActionLink("Preview", "EmailItemPreview", "Email", new { eventName=item.EventShortName, id=item.EmailItemId }, null)
                if (item.CanSendFromList)
                {
                    <text> | </text>@Html.ActionLink("Send", "SendFromList", "Email", new { eventName=item.EventShortName, id=item.EmailItemId }, null)
                }
                if (item.SiteUserId.HasValue)
                {
                }
            }
        </td>
        <td>@Html.DisplayFor(modelItem => item.EmailItemId)</td>
        <td>@Html.DisplayFor(modelItem => item.SendStatus)</td>
        <td>@String.Format("{0:yyyy-MM-dd  HH:mm}", item.SentUTC)</td>
        <td>@Html.DisplayFor(modelItem => item.EmailTo)</td>
        <td>@Html.DisplayFor(modelItem => item.FirstName)</td>
        <td>@Html.DisplayFor(modelItem => item.LastName)</td>
        <td>@Html.DisplayFor(modelItem => item.SubjectToUse)</td>
        <td>@Html.DisplayFor(modelItem => item.SentBy)</td>
    </tr>
}

</table>
